package com.liuxw.www.controller;

import com.liuxw.www.bean.JsonResult;
import com.liuxw.www.bean.Liuxw;
import com.liuxw.www.service.LiuxwService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.LinkedHashMap;

@Controller
@RequestMapping("/liuxw")
public class LiuxwController {

    @Resource
    private LiuxwService liuxwService;

    @RequestMapping({"/view"})
    public String view() {
        return "/liuxw.html";
    }

    // 新增
    @RequestMapping({"/add"})
    @ResponseBody
    public JsonResult add(Liuxw liuxw) {
        return liuxwService.save(liuxw);
    }

    // 修改
    @RequestMapping({"/edit"})
    @ResponseBody
    public JsonResult edit(Liuxw liuxw) {
        return liuxwService.update(liuxw);
    }

    // 删除
    @RequestMapping({"/delete/{ids}"})
    @ResponseBody
    public JsonResult delete(@PathVariable String ids) {
        return liuxwService.delete(ids);
    }

    // 查看
    @RequestMapping({"/get/{id}"})
    @ResponseBody
    public JsonResult get(@PathVariable Object id) {
        return liuxwService.select(id);
    }

    // 查询
    @RequestMapping({"/search"})
    @ResponseBody
    public JsonResult search(Liuxw liuxw) {
        LinkedHashMap map = new LinkedHashMap();
        map.put("liuxw", liuxw);
        return liuxwService.selectList(map);
    }

    // 查询基金
    @RequestMapping({"/searchFund"})
    @ResponseBody
    public JsonResult searchFund() {
        return liuxwService.selectListFundTs();
    }

    // 查看基金
    @RequestMapping({"/selectFund"})
    @ResponseBody
    public JsonResult selectFund(String fundCode) {
        return liuxwService.selectFund(fundCode);
    }

    // 查询基金名称
    @RequestMapping({"/searchFundName"})
    @ResponseBody
    public JsonResult searchFundName(String fundName) {
        return liuxwService.selectListFundName(fundName);
    }
}
